(:
  A procedure to select the contents of the "chat" interventions
:)
declare boundary-space strip;
import module namespace
    jj = "http://kumquat.emse.fr/utilitaires"
    at "jjutils.xq" ;
<display>{
let $t := $arguments[1]
let $d := doc($t)//record[message/messageHeader/@messageType="GenericType" and
       message/messageHeader/@UserName!="SERVER"][message/MLThreadedChatMessage]
for $e at $p in $d
let $m := ($e/message/MLThreadedChatMessage)
return
  <item>{ 
    <info name="type">threaded-chat</info>,
    <info name="time"><time><date>{fn:string($e/timestamp/@millis)}</date></time></info>,
    <info name="src-anchor"><anchor>{
      <doc>{ $t }</doc>,
      <path>{jj:build-Path($e)}</path>
    }</anchor></info>,
    <info name="user">{string($e/message/messageHeader/@UserName)}</info>,
    <info name="chat-category">{string($m/@category)}</info>,
    <info name="chat-tag">{string($m/@contributionTag)}</info>,
    <info name="content"><text color="green">{string($m/@text)}</text></info>
  }</item>
}</display>
